import Vue from 'vue'
import VueRouter from 'vue-router'

/* commonjs风格的导入 require Home '../views/Home.vue'*/
// ES6风格的模块导入
import Home from '../views/Home.vue'
import TodoListDemo from '@/views/TodoListDemo.vue'

Vue.use(VueRouter)

/* 定义路由 */
const routes = [

  /* 当路由为/时 加载Home组件 */
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  
  /* 异步加载组件：当用户输入路由/about时 异步加载（大组件）  */
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  },

  {
    path: '/todo',
    name: 'TodoListDemo',
    component: TodoListDemo
  },
  
]

const router = new VueRouter({
  routes
})

export default router
